#include "autobootui.h"
#include <QVBoxLayout>

AutoBootUi::AutoBootUi(QWidget *parent) : QWidget(parent)
{
    initUi();
}

void AutoBootUi::initUi()
{
    QVBoxLayout *vLyt = new QVBoxLayout(this);
    vLyt->setSpacing(8);
    vLyt->setContentsMargins(0, 0, 0, 0);

    TitleLabel *mTitleLabel = new TitleLabel(this);
    //~ contents_path /autoboot/Autoboot Settings
    mTitleLabel->setText(tr("Autoboot Settings"));

    mAutobootWidget = new SettingGroup(this);

    mAddWidget = new UkccFrame(mAutobootWidget);
    mAddWidget->setLineWidth(0);
    QHBoxLayout *Lyt = new QHBoxLayout(mAddWidget);
    Lyt->setContentsMargins(0, 0, 0, 0);
    mAddBtn = new AddBtn(mAddWidget);
    //~ contents_path /autoboot/Add
    mAddBtn->setBtnStyle(AddBtn::Bottom);
    Lyt->addWidget(mAddBtn);

    vLyt->addWidget(mTitleLabel);
    vLyt->addWidget(mAutobootWidget);
    vLyt->addStretch();
}

void AutoBootUi::resetUi()
{
    if (this->layout() != NULL) {
        QLayoutItem *item;
        while ((item = this->layout()->takeAt(0)) != NULL)
        {
            if(item->widget()) {
               item->widget()->setParent(NULL);
            }
            delete item;
            item = nullptr;
        }
    }
    delete this->layout();
    initUi();
}
